package com.iqik.filter.server;

import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

//@Activate(group = {CommonConstants.PROVIDER})
public class ServiceTransportIPFilter implements Filter {
    private static final Logger LOGGER = LoggerFactory.getLogger(ServiceTransportIPFilter.class);
    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        try {
            LOGGER.info("Request remote address: {}", RpcContext.getContext().getAttachment("address"));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return invoker.invoke(invocation);
    }
}
